#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double* input();
void calculate(double * in);
void sum(double* m, double* n);
void difference(double* m, double* n);
void product(double* m, double* n);
void division(double* m, double* n);

void myremainder(double* m, double* n);

int main()
{
	double* in_ptr;
	in_ptr = input();
	calculate(in_ptr);
	free(in_ptr);
	return 0;
}

double* input()
{
	double* in = malloc(2 * sizeof(double));
	printf("input two numbers:");
	scanf("%lf %lf",in , (in+1));
	return in;
}

void calculate(double * in)
{
	printf("choose:\n1 sum\n2 difference\n3 product\n4 division\n5 remainder\n");
	int mathed;
	scanf("%d", &mathed);
	switch (mathed){
		case 1:
			sum(in, in+1);
			break;
		case 2:
			difference(in, in+1);
			break;
		case 3:
			product(in, in+1);
			break;
		case 4:
			division(in, in+1);
			break;
		case 5:
			myremainder(in, in+1);
			break;
		default:
			printf("invalid input\n");
			break;
	}
}

void sum(double* m, double* n)
{
	printf("%lf\n", *m + *n);
}

void difference(double* m, double* n)
{
	printf("%lf\n", *m - *n);
}
void product(double* m, double* n)
{
        printf("%lf\n", *m * *n);
}
void division(double* m, double* n)
{
	if(n != 0)printf("%lf\n", *m / *n);
	else printf("invalid input\n");
}
void myremainder(double* m, double* n)
{
	printf("%d\n", (int)*m % (int)*n);
}
